unit globaldatos;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, Windows;

function GetVersion: String;
procedure SetVersion();

procedure Set64Bits(s : Boolean);
function Get64Bits : Boolean;

function Is64bitOS: boolean;
var
  Version : String;
  Sistema64 : Boolean;
implementation
function GetVersion: String;
Begin
  Result := Version;
end;

procedure SetVersion();
Begin
  Version := '0.2.0.0';
end;
procedure Set64Bits(s : Boolean);
Begin
  Sistema64 := s;
End;

function Get64Bits : Boolean;
Begin
  Result := Sistema64;
end;

{ Función para identificar si el SO es de 64 bits. }
function Is64bitOS: boolean;
{
Detect if we are running on a 64 bit or 32 bit operating system/kernel
independently of bitness of this program, or actual hardware.
Original source:
http://www.delphipraxis.net/118485-ermitteln-ob-32-bit-oder-64-bit-betriebssystem.html
modified for FreePascal in German Lazarus forum:
http://www.lazarusforum.de/viewtopic.php?f=55&t=5287
}

type
  TIsWow64Process = function( // Type of IsWow64Process API fn
      Handle: Windows.THandle; var Res: Windows.BOOL): Windows.BOOL; stdcall;
var
  IsWow64Result: Windows.BOOL; // Result from IsWow64Process
  IsWow64Process: TIsWow64Process; // IsWow64Process fn reference
begin
  // Try to load required function from kernel32
  IsWow64Process := TIsWow64Process(Windows.GetProcAddress(
    Windows.GetModuleHandle('kernel32'), 'IsWow64Process'));
  if Assigned(IsWow64Process) then
  begin
    // Function is implemented: call it
    if not IsWow64Process(Windows.GetCurrentProcess, IsWow64Result) then
      raise SysUtils.Exception.Create('IsWindows64: bad process handle');
    // Return result of function
    Result := IsWow64Result;
  end
  else
    // Function not implemented: can't be running on Wow64
    Result := False;
end;

end.

